"use strict";
cc._RF.push(module, '747cevv4vpFBoXi/Zfis9wD', 'card');
// scripts/card.ts

"use strict";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var log = console.log;
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Card = /** @class */ (function (_super) {
    __extends(Card, _super);
    function Card() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.background = null;
        _this.SelectBack = null;
        _this.cardTypes = [];
        _this.chosenFlag = {
            Value: false, delegate: null,
            set value(val) {
                if (this.delegate && val != this.Value)
                    this.delegate(val);
                this.Value = val;
            },
            get value() { return this.Value; }
        };
        _this.hoverFlag = {
            Value: false, delegate: null,
            set value(val) {
                if (this.delegate && val != this.Value)
                    this.delegate(val);
                this.Value = val;
            },
            get value() { return this.Value; }
        };
        _this.touchStart = function () { };
        _this.touchMove = function () { };
        _this.Idx = -1;
        _this.moveFlag = false;
        return _this;
    }
    Card.prototype.choose = function (chooseVal) {
        if (chooseVal === void 0) { chooseVal = null; }
        this.chosenFlag.value = chooseVal != null ? chooseVal : !this.chosenFlag.value;
    };
    Card.prototype.hover = function (hoverVal) {
        if (hoverVal === void 0) { hoverVal = null; }
        this.hoverFlag.value = hoverVal != null ? hoverVal : !this.hoverFlag.value;
    };
    Card.prototype.getChoose = function () {
        return this.chosenFlag.value;
    };
    Card.prototype.InitCard = function (info) {
        this.initCard(info.type, info.text, info.color);
    };
    Card.prototype.initCard = function (type, text, color) {
        var _this = this;
        this.chosenFlag.delegate = function (chosen) {
            _this.node.y += chosen ? _this.node.height / 3 : -_this.node.height / 3;
        };
        this.hoverFlag.delegate = function (hover) {
            _this.node.getComponent(cc.Sprite).spriteFrame = hover ? _this.SelectBack : _this.background;
        };
        if (type)
            this.node.getChildByName('type').getComponent(cc.Sprite).spriteFrame = this.cardTypes[['fk', 'ht', 'hx', 'mh'].indexOf(type)];
        if (!type) {
            var valueNode = this.node.getChildByName('value');
            valueNode.y = 0;
            valueNode.getComponent(cc.Label).fontSize = 18;
            valueNode.getComponent(cc.Label).lineHeight = 18;
            this.node.getChildByName('type').getComponent(cc.Sprite).spriteFrame = null;
        }
        this.node.getChildByName('value').getComponent(cc.Label).string = text;
        this.node.getChildByName('value').color = color == 'RED' ? cc.Color.RED : cc.Color.BLACK;
        this.node.getComponent(cc.Sprite).spriteFrame = this.background;
    };
    __decorate([
        property(cc.SpriteFrame)
    ], Card.prototype, "background", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], Card.prototype, "SelectBack", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], Card.prototype, "cardTypes", void 0);
    Card = __decorate([
        ccclass
    ], Card);
    return Card;
}(cc.Component));
exports.default = Card;

cc._RF.pop();